<?php
    @session_start();
    include("template/head.php");
?>
<script>
function showArticle()
{
	artile_id = emp = document.getElementById("select01");
	id=artile_id.options[artile_id.selectedIndex].value;
	 var xhReq = new XMLHttpRequest();
	 xhReq.open("GET", "ajax/getArticle.php?q="+id, false);
	 xhReq.send(null);
	 var serverResponse = xhReq.responseText;
 if(serverResponse!=""){
    var array = [];
	array = JSON.parse(serverResponse);
	document.getElementById('designation').value = array.designation;
	// Add Unité de stockage
	unit = document.getElementById("unit");
	var lengthUnit = unit.options.length;
    for(i = 0; i < lengthUnit; i++)
    {
      // check the current option's text if it's the same with the input box
      if (unit.options[i].value == array.unit_stock)
      {
         unit.selectedIndex = i;
         break;
      }     
    }
 }
}
</script>
    <div class="container-fluid">
        <div class="row-fluid">
                
        <?php include("template/menu_left.php") ?>                
         <div class="span10" id="content">
            <div class="row-fluid">
			<form id="formAddIntervention" class="form-horizontal"  enctype="multipart/form-data" method="POST" action="submit/sortie/add_sortie.php">
            <!-- block -->
                <!--  ************************ ROW ************************  -->
              <div class="span12">   
                 <div class="block">
                    <div class="navbar navbar-inner block-header">
                        <div class="muted pull-left">Ajouter une sortie</div>
                        <!-- .toolbar -->
                    </div>   
                    <div class="block-content in" id="div-1">
                    <div class="control-group">  
                        <label class="control-label span4" for="ref_article">Réference Article</label>
                          <div class="controls">
							<select class="validate[required] chzn-select" id="select01" name="ref_article" onchange="showArticle()">
        					<option value="">Selectionner</option>
							<?php
								$table = "SELECT DISTINCT (`ref_article`), `id_article`, `photo_name` FROM st_article ORDER BY id_article ASC;";     
								$colonne = mysql_query($table);     
								while($data = mysql_fetch_array($colonne)){
								echo '<option value="'.$data["id_article"].'">'.$data["ref_article"].'</option>';
								}
							?>
							</select>	
                          </div>
                    </div>
                    <div class="control-group">
                        <label for="comment" class="control-label span4"  for="pass1">Désignation</label>
                    	<div class="controls">
                    		<textarea name="designation" class="validate[required,custom[integer]] form-control span5" placeholder="Désignation" id="designation" disabled></textarea>
                       </div>
                    </div>
                    <div class="control-group">  
                        <label class="control-label span4" for="ref_article">Quantité</label>
                          <div class="controls">
                            <input type="text" name="qte" class="validate[required] form-control" placeholder="Quantité" id="form-validation-field-1">
                         	
                          </div>
                    	</div>
                        <div class="control-group">
                            <label for="comment" class="control-label span4">Date Ajout</label>
                            <div class="controls">
                            	<input type="text" data-color-format="rgb" data-color="rgb(255, 146, 180)" data-date-format="dd/mm/yyyy" name="dateAdd" id="date01" value="<?php echo date('d/m/Y')?>" class="datepicker">
                            </div>
                        </div>

                        <div class="control-group">  
                        <label class="control-label span4" for="ref_article">Unité de vente</label>
                          <div class="controls">
                          <select class="validate[required] form-control chzn-select" id="select02" name="id_unite">
                              <option value="">Selectionner</option>
                          <?php
                            $table = "SELECT DISTINCT `raison_social`, `id_unite` FROM st_att_unite ORDER BY raison_social DESC;";     
                            $colonne = mysql_query($table);     
                            while($data = mysql_fetch_array($colonne)){
                            echo '<option value="'.$data["id_unite"].'">'.$data["raison_social"].'</option>';
                            }
                          ?>
                          </select> 
                                      </div>
                                </div>

                        <div class="control-group">
                            <label for="comment" class="control-label span4">Note</label>
                            <div class="controls">
                          	<textarea id="comment" name="comment" placeholder="Mettez votre note ici..." class="span8 form-control"></textarea>
                            </div>
                        </div>  
                             <!-- /.control-group -->

                    </div>
                    </div>
              </div>
            <!--  ************************ / ROW ************************  -->
            
              <div class="span12" style="margin-left:0px;">
              <div class="form-group">
                <div class="col-lg-8">
                    <input type="submit" value="Ajouter" class="validate[required] span3 btn btn-primary" style="margin-bottom:1em; float: right;" name="marque_ajout">
               </div>
          </div>         
             </form>   
            </div>
          
          </div>
            <hr>
        </div>
<?php  include("template/footer_vente_achat.php") ; ?>